import axios from '../utils/axios';

const token = localStorage.getItem('token')

export const getMenu = async () => {

    let response = {}
    await axios.get('/api/menus/build', {
        headers: {
            Authorization: token
        }
    })
        .then((res) => {
            response = res
        })
        .catch((error) => {
            response = error.response
        })

    return response
}

export const createMenu = async (data) => {
    let response = {}
    await axios.post('/api/menus', data, { headers: { Authorization: token }, })
        .then((res) => {
            response = res
        })
        .catch((error) => {
            response = error.response
        })

    return response
}


export const updateMenu = async (data) => {
    let response = {}
    await axios.put('/api/menus', data, { headers: { Authorization: token }, })
        .then((res) => {
            response = res
        })
        .catch((error) => {
            response = error.response
        })

    return response
}

export const deleteMenu = async (params) => {
    let response = {}
    await axios.request({
        url: `/api/menus`,
        method: 'delete',
        data: params,
        headers: { Authorization: token }
    })
        .then((res) => {
            response = res
        })
        .catch((error) => {
            response = error.response
        })
    return response
}
